﻿@model MaterialPrice
@{
    ViewBag.Title = "采购价格维护";
    Layout = "~/Views/Shared/_LayoutForm.cshtml"; 
}
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.MaterialId)
@Html.nbButtonEditFor(model => model.MaterialName, "SetPrice")
@Html.nbDropDownListFor(model => model.SupplierId, "Supplier")
@Html.nbDropDownListFor(m => m.BigClass, "BigClass").Required()
@Html.nbDropDownListFor(m => m.Specification, "MaterialSpec")
@Html.nbDropDownListFor(m => m.Category, "MaterialCategory").Required()
@Html.nbDropDownListFor(m => m.Unit, "MaterialUnit").Required()
@Html.nbTextBoxFor(model => model.Price).Number()
@Html.nbTextBoxFor(model => model.PrePrice).Disable()
@Html.nbDateFor(model => model.StartDate)
@Html.nbDateFor(model => model.EndDate).CompareDate("StartDate")
@Html.nbTextAreaFor(model => model.Remark)
<script type="text/javascript">
    function SetPrice() {
        OpenModalDialog('@Url.Action("SingleLookUp", "Material", new { p1 = "RawMaterial" })',
        {
            caption: "选择原材料",
            width: 800,
            height: 500,
            type: 2,
            onclose: function (data) {
                if (data) {
                    $("#MaterialId").val(data.Id);
                    $("#MaterialName").val(data.Name);
                    $("#Specification").val(data.Specification);
                    $("#Unit").val(data.Unit);
                    $("#Category").val(data.Category);
                    $("#BigClass").val(data.BigClass);
                    if ($("#PrePrice").val() == "0") {
                        // 获取最后一期的价格
                        ajaxTodo('@Url.Action("GetPrePrice")', { MaterialId: data.Id }, function (result) {
                            if (result.IsSuccess) {
                                $("#PrePrice").val(result.Data);
                            }
                        }, "", false);
                    }
                }
            }
        });
    }
</script>
